package io.xiaojl.xj2ee.modules.sys.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import io.xiaojl.xj2ee.modules.sys.entity.SysRoleMenuEntity;

/**  
 * <p>Title: SysRoleMenuRepository</p>  
 *
 * <p>Description: 实现基本的CRUD还有分页操作</p>  
 *
 * @author jilong.xiao  
 * @date 2018年9月27日  
 */
public interface SysRoleMenuRepository extends JpaRepository<SysRoleMenuEntity, Long> ,JpaSpecificationExecutor<SysRoleMenuEntity> {

	/**  
	 * <p>Title: queryMenuIdList</p>  
	 * <p>Description: </p>  
	 *
	 * @param roleId
	 * @return  
	 */ 
	@Query(value="select menuId from sys_role_menu where roleId =:roleId",nativeQuery=true)
	List<Long> queryMenuIdList(@Param("roleId")Long roleId);

	/**  
	 * <p>Title: deleteBatchByRoleIds</p>  
	 * <p>Description: </p>  
	 * @param roleIds
	 * @return  
	 */ 
	@Modifying
	@Query(value="delete from sys_role_menu where roleId in(:roleIds)",nativeQuery=true)
	int deleteBatchByRoleIds(@Param("roleIds")Long[] roleIds);

	/**  
	 * <p>Title: deleteByMenuId</p>  
	 * <p>Description: </p>  
	 *
	 * @param menuId  
	 */ 
	@Modifying
	@Query(value="delete from sys_role_menu where menuId =:menuId",nativeQuery=true)
	void deleteByMenuId(@Param("menuId")Long menuId);


}
